-
Notifications
You must be signed in to change notification settings - Fork 280
examples: fix mypy errors in example entry points; add local type-check script (#1091) #1248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
georgeh0
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the cleanups!
examples/custom_output_files/main.py
Outdated
| @cocoindex.op.function() | ||
| def markdown_to_html(text: str) -> str: | ||
| return _markdown_it.render(text) | ||
| return cast(str, _markdown_it.render(text)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking about also considering code simplicity/readability. Given these examples are for users to understand how to use cocoindex, this matters.
For case like this, it's essentially the underlying library doesn't have a specific type, and the return type of the current function is clear.
I think we can just ignore it by a comment like # type: ignore
(IMO cast(...) is more useful for values within a function - from the point on, the type is clear)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please resolve this comment and avoid cast(...) for function return types, and use # type: ignore comment instead. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
…s, minimal ignores)
|
is it fine this time? |
Hi @samojavo, please resolve the first comment above. Thanks! |
• Make all example entry points pass mypy when run individually (with --ignore-missing-imports).
• Add a small helper script (dev/mypy_check_examples.ps1) and a brief note in dev/README.md.
Closes #1091